$.fn.wresize = function (callback) {
    version = '1.1';
    wresize = { fired: false, _lastWidth: 0, _lastHeight: 0 };
    timeout = 50;
    timerId = false;

    function handleWResize(e) {
        if (timerId) {
            clearTimeout(timerId);
        }
        timerId = setTimeout(function () {
           return callback.apply(this, [e]);
        }, 200);
    }

    this.each(function () {
        if (this == window) {
            $(this).resize(handleWResize);
        }
        else {
            $(this).resize(callback);
        }
    });

    return this;
};